< previous page page_410 next page >

Page 410
    DWORD dwServiceSpecificExitCode;
    DWORD dwCheckPoint;
    DWORD dwWaitHint;
} SERVICE_STATUS, *LPSERVICE_STATUS;
The first two fields of the ENUM_SERVICE_STATUS structures are strings. But if your first reaction is to assume that these will translate into Visual Basic strings, stop reading and go back immediately to Tutorial 7, ''Classes, Structures, and User-Defined Types," to find out why that is a sure road to disaster. These fields must be defined as Long variables, as shown in these type declarations:
Public Type ENUM_SERVICE_STATUS
    lpServiceName As Long
    lpDisplayName As Long
    Status As SERVICE_STATUS
End Type

' Service structures
Public Type SERVICE_STATUS
    dwServiceType As Long
    dwCurrentState As Long
    dwControlsAccepted As Long
    dwWin32ExitCode As Long
    dwServiceSpecificExitCode As Long
    dwCheckPoint As Long
    dwWaitHint As Long
End Type
These structures contain pointers to strings. But where are the strings?
The buffer that is loaded with ENUM_SERVICE_STATUS structures contains the strings as well. Figure T10-1 illustrates a typical buffer that has been loaded by two of these structures.
The buffer is loaded with one or more ENUM_SERVICE_STATUS structures. The buffer also contains any strings that are pointed to by the structure fields. The buffer is initially set to 512, an arbitrary number. On return, the EnumServicesStatus API will
1. Load the buffer with as many ENUM_SERVICES_STATUS structures as will fit,
2. Set the ServicesReturned parameter to the number of services returned,

 
< previous page page_410 next page >